package com.sdkj.recruit.dao.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Persistent;
import org.springframework.stereotype.Service;

import com.sdkj.recruit.dao.IMongodbDAO;
import com.sdkj.recruit.dao.IWechatTokenDao;
import com.sdkj.recruit.mongoSupport.QueryParamCreator;
import com.sdkj.recruit.wechat.WechatToken;

@Persistent
@Service("wechatToken")
public class WechatTokenDao implements IWechatTokenDao{

	@Autowired
	private IMongodbDAO dao;

	@Override
	public com.sdkj.recruit.wechat.WechatToken queryTokenByAppId(String appId) {
		return dao.getPO(WechatToken.class, QueryParamCreator.eq("appId", appId));
	}

	@Override
	public void saveToken(WechatToken wt) {
		dao.saveOrUpdatePO(wt);
	}

	@Override
	public void updataToken(String appid, Map<String, Object> map) {
		dao.saveOrUpdateDocument(WechatToken.class, map, QueryParamCreator.eq("appId", appid));
	}
	
}
